	***********************************************************************************
	* Inter-regional Inequality and the Dynamics of Government Spending 
	* Online Appendix -- Section 5. Regional Identity
	***********************************************************************************
	clear all
	set more off 
	set mem 600m
	cd "YOUR_DIRECTORY_PATH_HERE\supplements (online appendix)\appendix g"
	use "onlineappendix.dta"   

 	*************************************
	** Rescaling / Modifying Variables                              
	*************************************
	sort id year 
	sum ideal_pt_V1, meanonly
	gen jacoby_modified2 = ideal_pt_V1 - `r(mean)'
	replace adgini = adgini*100
	replace jacoby_modified2 = jacoby_modified2*100
	replace ineq_spns = ineq_spns*100
	gen log_pop = log(pop)	
	gen log_rgdpch = log(rgdpch)
	gen pop14_65 = popunder14 + popover65
	replace ph=ph*100       
	replace ethnicity_C2=ethnicity_C2*100
	replace ethnicity_I=ethnicity_I*100
	
	**************************************
	* Generate five-year moving averages 
	**************************************
	foreach x of varlist adgini rpop_s1_rgdppc ///
    log_pop pop14_65 a log_rgdpch gov_left2 {
	gen ma`x' = (l1.`x' + l2.`x' + l3.`x' + l4.`x'+ l5.`x')/5
	}

    ************************
	** Renaming Variables 
	************************
    rename govexp_central_cofog2 central_govtsp
	rename jacoby_modified2 policy_priority
    rename maadgini rdgini
	rename marpop_s1_rgdppc mm_ratio
	rename malog_pop population_logged
	rename mapop14_65 dependent_population 
	rename maa economic_globalization
	rename malog_rgdpch ppp_gdppc_logged
	rename magov_left2 leftistgovt
	rename Parl parliamentary
	rename Unit2 nonfed_nonbicam
	rename ph linguistic_heterogeneity
	rename ethnicity_C2 ethnic_segregation
	rename ethnicity_I ethnic_fractionalization
	
	**************************************************************
	** Appendix G. Additional Controls for Regional Identity
	**************************************************************
	tab countries, gen(kcountry_)
	global baseline l.population_logged l.d.population_logged l.dependent_population l.d.dependent_population l.economic_globalization l.d.economic_globalization l.ppp_gdppc_logged l.d.ppp_gdppc_logged l.leftistgovt 
	
	* Model [1]
	xi:xtpcse d.central_govtsp l.central_govtsp l.rdgini $baseline l.PR l.parliamentary l.nonfed_nonbicam l.linguistic_heterogeneity kcountry_* if year>=1991 & year<=2011, pairwise corr(ar1) noconst
	tempname r2_a
	scalar `r2_a' = 1 - (1 - e(r2))*( e(N) -1)/(e(N)-e(n_cf)-1)
	di in green "Adj R-Squared = " %-6.4f `r2_a'
	
	* Model [2]
	xi:xtpcse d.central_govtsp l.central_govtsp l.rdgini $baseline l.PR l.parliamentary l.nonfed_nonbicam l.ethnic_segregation l.ethnic_fractionalization kcountry_* if year>=1991 & year<=2011, pairwise corr(ar1) noconst 
	tempname r2_a
	scalar `r2_a' = 1 - (1 - e(r2))*( e(N) -1)/(e(N)-e(n_cf)-1)
	di in green "Adj R-Squared = " %-6.4f `r2_a'
	
	* Model [3]
	xi:xtpcse d.central_govtsp l.central_govtsp l.mm_ratio $baseline l.PR l.parliamentary l.nonfed_nonbicam l.linguistic_heterogeneity kcountry_* if year>=1991 & year<=2011, pairwise corr(ar1) noconst
	tempname r2_a
	scalar `r2_a' = 1 - (1 - e(r2))*( e(N) -1)/(e(N)-e(n_cf)-1)
	di in green "Adj R-Squared = " %-6.4f `r2_a'
	
	* Model [4]
	xi:xtpcse d.central_govtsp l.central_govtsp l.mm_ratio $baseline l.PR l.parliamentary l.nonfed_nonbicam l.ethnic_segregation l.ethnic_fractionalization kcountry_* if year>=1991 & year<=2011, pairwise corr(ar1) noconst
	tempname r2_a
	scalar `r2_a' = 1 - (1 - e(r2))*( e(N) -1)/(e(N)-e(n_cf)-1)
	di in green "Adj R-Squared = " %-6.4f `r2_a'
	
    * Model [5]
	xi:xtpcse d.policy_priority l.policy_priority l.rdgini $baseline l.PR l.parliamentary l.nonfed_nonbicam l.linguistic_heterogeneity kcountry_* if year>=1991 & year<=2011, pairwise corr(ar1) noconst
	tempname r2_a
	scalar `r2_a' = 1 - (1 - e(r2))*( e(N) -1)/(e(N)-e(n_cf)-1)
	di in green "Adj R-Squared = " %-6.4f `r2_a'
	
    * Model [6]
	xi:xtpcse d.policy_priority l.policy_priority l.rdgini $baseline l.PR l.parliamentary l.nonfed_nonbicam l.ethnic_segregation l.ethnic_fractionalization kcountry_* if year>=1991 & year<=2011, pairwise corr(ar1) noconst
	tempname r2_a
	scalar `r2_a' = 1 - (1 - e(r2))*( e(N) -1)/(e(N)-e(n_cf)-1)
	di in green "Adj R-Squared = " %-6.4f `r2_a'
	
    * Model [7]
	xi:xtpcse d.policy_priority l.policy_priority l.mm_ratio $baseline l.PR l.parliamentary l.nonfed_nonbicam l.linguistic_heterogeneity kcountry_* if year>=1991 & year<=2011, pairwise corr(ar1) noconst
	tempname r2_a
	scalar `r2_a' = 1 - (1 - e(r2))*( e(N) -1)/(e(N)-e(n_cf)-1)
	di in green "Adj R-Squared = " %-6.4f `r2_a'

    * Model [8]	
	xi:xtpcse d.policy_priority l.policy_priority l.mm_ratio $baseline l.PR l.parliamentary l.nonfed_nonbicam l.ethnic_segregation l.ethnic_fractionalization kcountry_* if year>=1991 & year<=2011, pairwise corr(ar1) noconst
	tempname r2_a
	scalar `r2_a' = 1 - (1 - e(r2))*( e(N) -1)/(e(N)-e(n_cf)-1)
	di in green "Adj R-Squared = " %-6.4f `r2_a'
	
